<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/jsp/include/head.jsp"/>
    <style>
        .detailTable {
            margin-bottom: 0px;
        }
        .detailTable th {
            width: 26%;
        }
        .detailTable td {
            width: 37%;
        }
    </style>
</head>
<body>
<ol class="breadcrumb">
    <li><strong>当前位置： </strong>标准化管理</li>
    <li class="active">中心领导复查</li>
</ol>


<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title selectslid" style="display: inline-block">查询</h3>
            <a role="button" id="btn_agreeList" style="float: right"
               class="btn btn-default btn-xs btn-info"
               href="javaScript:;"><span class="glyphicon glyphicon-ok"></span> 批量同意</a>
    </div>
    <div class="panel-body">
        <form id="form_search" class="form-horizontal row">
            <div class="form-group col-sm-4 ">
                <label class="control-label col-sm-4 ">专家姓名：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="expertName">
                </div>
            </div>

            <div class="form-group col-sm-4 ">
                <label class="col-sm-4 control-label">信息类型：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="entityName">
                        <option value="">&nbsp;</option>
                        <option value="EMS_EXPERT_BASE">基本信息</option>
                        <option value="EMS_EXPERT_COMPANY">工作单位</option>
                        <option value="EMS_EXPERT_CERTIFICATE">资质证书</option>
                        <option value="EMS_EXPERT_MAJOR">从事专业</option>
                        <option value="EMS_EXPERT_WORK">工作经历</option>
                        <option value="EMS_EXPERT_TRAIN">培训经历</option>
                        <option value="EMS_EXPERT_EDUCATION">教育经历</option>
                        <option value="EMS_EXPERT_REVIEW">审查/评审经历</option>
                    </select>
                </div>
            </div>
            <div class="form-group col-sm-2">
                <div class="col-sm-8 col-sm-offset-4">
                    <button id="btn_search" type="button" class="btn btn-default "><span
                            class="glyphicon glyphicon-search"></span>&nbsp;查&nbsp;询&nbsp;</button>
                </div>
            </div>
        </form>
    </div>
</div>


<table id="table_data"></table>


<div class="modal fade" id="modal_ajax">
    <div class="modal-dialog    modal-lg ">
        <div class="modal-content ">
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>


<script>


    var $table_data = $('#table_data');
    $("#btn_search").click(function () {
        refreshTable()
    });

    function refreshTable() {
        $table_data.bootstrapTable('refresh');
    }

    var entityName = {
        "EMS_EXPERT_BASE": "基本信息",
        "EMS_EXPERT_COMPANY": "工作单位",
        "EMS_EXPERT_CERTIFICATE": "资质证书",
        "EMS_EXPERT_MAJOR": "从事专业",
        "EMS_EXPERT_WORK": "工作经历",
        "EMS_EXPERT_TRAIN": "培训经历",
        "EMS_EXPERT_EDUCATION": "教育经历",
        "EMS_EXPERT_REVIEW": "审查/评审经历"
    };

    $table_data.bootstrapTable({
        url: 'expertInfo/leader2Check/select',
        striped: true,
        cache: false,
        sidePagination: 'server',
        pageSize: 10,
        pageList: [10, 30, 50, 100, 300],
        pageNumber: 1,
        pagination: true,
        queryParams: function (params) {
            $.extend(params, $("#form_search").serializeObject());
            return params
        },
        columns: [
            {
                checkbox: true
            },
            {
                formatter: function (value, row, index) {
                    return [
                        index + 1
                    ].join('');
                }
            },
            {
                title: '生成时间',
                field: "verifier1OperateDate",
                formatter: function (value, row, index) {
                    return $.Helper.dataTimeHelper.int2DateTimeString(value);
                }
            },
            {
                field: 'expertName',
                title: '专家姓名'

            },
            {
                field: 'expertIdCard',
                title: '身份证号'
            },
            {
                field: 'operateType',
                title: '操作类型',
                formatter: function (value, row, index) {
                   return $.sysPlugin.ifElse(value, $.sysPlugin.enumeration.operationType);
                }
            },
            {
                field: 'tableName',
                title: '详细信息',
                events: 'operateEvents',
                formatter: function (value, row, index) {
                    var s = $.sysPlugin.ifElse(value, entityName);
                    return [
                        '<a class="tableNameClick" href="javascript:;" >' + s + '</a>'
                    ].join('');
                }
            },

            {
                field: 'verifier1Name',
                title: '管理员'

            },

            {
                field: 'verifier2Name',
                title: '部门领导'

            },



            {
                title: '操作',
                events: 'operateEvents',
                formatter: function (value, row, index) {

                    return [
                        '<div class="btn-group btn-group-xs" role="group" >'
                        + '<button type="button" class="btn btn-xs btn-default   agree_data">' +
                        '<span class="glyphicon glyphicon-ok  "></span> 同意' +
                        '</button>'
                        + '<button type="button" class="btn btn-xs btn-default  disagree_data">' +
                        '<span class="glyphicon glyphicon-remove"></span> 驳回' +
                        '</button>'
                        + '</div>'
                    ].join('');


                }
            }
        ]
    });


    $("#btn_agreeList").click(function () {
        var rows = $table_data.bootstrapTable('getSelections');
        if (rows.length == 0) {
            swal("", "至少勾选一条记录");
            return;
        }
        var ids = [];
        $.each(rows, function (i, v) {
            ids.push(v.id);
        });


        $.sysPlugin.superAjax({
            data: {
                ids: ids,
            },
            url: "expertInfo/leader2Check/setResultList",
            operateType: '批量通过',
            showSuccessAlert: true,
            showWarnAlert: true,
            successCall: function (data) {
                refreshTable();
            }
        });

    });


    var url = 'expertInfo/leader2Check/setResult';
    window.operateEvents = {
        'click .tableNameClick': function (e, value, row, index) {
            $('#modal_ajax').modal({
                backdrop: 'static',
                keyboard: false,
                show: true,
                remote: 'expertInfo/checkExpertInfoDlg/showDetail?id=' + row.id
            });
        },
        'click .finish_data': function (e, value, row, index) {
            $.sysPlugin.superAjax({
                data: {
                    id: row.id,
                    result: true,
                },
                url: url,
                operateType: '操作',
                showSuccessAlert: true,
                showWarnAlert: false,
                successCall: function (data) {
                    refreshTable();
                }
            });
        },
        'click .agree_data': function (e, value, row, index) {
            $.sysPlugin.superAjax({
                data: {
                    id: row.id,
                    result: true,
                },
                url: url,
                operateType: '审批',
                showSuccessAlert: true,
                showWarnAlert: false,
                successCall: function (data) {
                    refreshTable();
                }
            });
        },
        'click .disagree_data': function (e, value, row, index) {
            swal({
                        title: "",
                        text: "请详细说明驳回原因：",
                        type: "input",
                        showCancelButton: true,
                        closeOnConfirm: false,
                        animation: "slide-from-top",
                        inputPlaceholder: "不能为空！"
                    },
                    function (inputValue) {
                        if (inputValue === false) return false;
                        if (inputValue.trim() === "") {
                            swal.showInputError("驳回原因不能为空！");
                            return false
                        }
                        $.sysPlugin.superAjax({
                            data: {
                                id: row.id,
                                result: false,
                                reason: inputValue
                            },
                            url: url,
                            operateType: '驳回',
                            showSuccessAlert: true,
                            showWarnAlert: false,
                            successCall: function (data) {
                                refreshTable();
                            }
                        });
                    }
            );
        }
    };


    $.sysPlugin.clearModalRemoveData("modal_ajax");
    $.sysPlugin.initSimpleSelect2();

</script>
</body>
</html>
